package br.uefs.ecomp.myBook.util;

import static org.junit.Assert.*;

import java.util.LinkedList;

import org.junit.Before;
import org.junit.Test;

import br.uefs.ecomp.myBook.model.Profile;

public class JavaAddAllVertexTest {

	Vertex<Profile> v1, v2, v3, v4;
	LinkedList<Vertex<Profile>> list1, list2;
	
	@Before
	public void setUp() throws Exception {
		Profile p1, p2, p3, p4;
		p1 = new Profile("p1", "12345", "Joao", "null", "null", "Feira", /*"Precisa disso?",*/ "None");
		p2 = new Profile("p2", "12345", "Pedro", "null", "null", "Feira", /*"Precisa disso?",*/ "None");
		p3 = new Profile("p3", "12345", "Joao Pedro", "null", "null", "Feira da Mata", /*"Precisa disso?",*/ "None");
		p4 = new Profile("p4", "12345", "Maria Joao", "null", "null", "Feira de Santana", /*"Precisa disso?",*/ "None");
		v1 = new Vertex<>(p1);
		v2 = new Vertex<>(p2);
		v3 = new Vertex<>(p3);
		v4 = new Vertex<>(p4);
		list1 = new LinkedList<>();
		list2 = new LinkedList<>();
	}

	@Test
	public void test() {
		list1.add(v1);
		list1.add(v2);
		list2.addAll(list1);
		int i = 0;
		for(Vertex<Profile> v: list2){
			if(i == 0)
				assertEquals(v1, v);
			if(i == 1)
				assertEquals(v2, v);
			i++;
		}
		assertEquals(i, 2);
	}
	
	@Test
	public void testNeighbors() throws DataAlreadyExistsException {
		v1.addEdge(v2);
		v1.addEdge(v3);
		v1.addEdge(v4);
		
		list1.addAll(v1.getNeighbors());
		
		int i = 0;
		for(Vertex<Profile> v: list1){
			if(i == 0)
				assertEquals(v2, v);
			if(i == 1)
				assertEquals(v3, v);
			if(i == 2)
				assertEquals(v4, v);
			i++;
		}
		
		assertEquals(i, 3);
		
	}
}
